package cn.baisee.process.impl;

import cn.baisee.process.ProcessChain;
import cn.baisee.process.ProcessRequest;
import cn.baisee.request.GroundingRequest;
import cn.baisee.result.Result;

import java.util.List;

public class GoodsProcessChain implements ProcessChain {
    private GroundingRequest request;
    private List<ProcessRequest> list;
    private int index;

    public void setRequest(GroundingRequest request) {
        this.request = request;
    }

    public List<ProcessRequest> getList() {
        return list;
    }

    public void setList(List<ProcessRequest> list) {
        this.list = list;
    }

    public int getIndex() {
        return index;
    }

    public void setIndex(int index) {
        this.index = index;
    }

    public GroundingRequest getRequest() {
        return request ;
    }

    public Result doChain(GroundingRequest request) {
        System.out.println(list.size());
        if (list.size()>index){
            index++;

            this.setRequest(request);

          return list.get(index).doneRequest(this);

        }else {
            return null;
        }

    }
}
